<?php
/**
 * 热门城市
 */

namespace app\api\model;


use app\common\model\BaseModel;
use PDOStatement;
use think\Collection;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\exception\DbException;

class HotCity extends BaseModel {

    /**
     * 热门城市
     * @return array|PDOStatement|string|Collection
     * @throws DataNotFoundException
     * @throws ModelNotFoundException
     * @throws DbException
     */
    public static function getList() {
        $data = db('hot_city')
            ->field('city_code,x(location) as lng,Y(location) as lat,name')
            ->select();
        foreach ($data as $k => $v) {
            $data[$k]['lng'] = !empty($data[$k]['lng']) ? (string)$data[$k]['lng'] : '';
            $data[$k]['lat'] = !empty($data[$k]['lat']) ? (string)$data[$k]['lat'] : '';
        }
        return $data;
    }

}
